import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] price = new int[n];
        for(int i = 0; i < n; i++) {
            price[i] = in.nextInt();
        }

        int[] f = new int[n];
        int[] g = new int[n];
        f[0] = -price[0];
        g[0] = 0;
        for(int i = 1; i < n; i++) {
            f[i] = Math.max(f[i-1], g[i-1] - price[i]);
            g[i] = Math.max(g[i-1], f[i-1] + price[i]);
        }
        System.out.println(g[n-1]);
    }
}